using SM.core;
using SS;
using SS.core;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
namespace TVSBH.doctor
{
	public class frmTmpPrescription : Form
	{
		private IContainer components = null;
		private DataGridView dgvBill;
		private Button btnClose;
		private Button btnDel;
		private Button btnSave;
		private Button btnEdit;
		private Button btnAdd;
		private DataGridView dgvProduct;
		private Button btnSelect;
		private Button btnAddToBill;
		private TextBox txtProductUnit;
		private TextBox txtProductName;
		private ToolTip toolTip1;
		private ContextMenuStrip cmsBill;
		private ToolStripMenuItem cmsDelProduct;
		private ToolStripSeparator toolStripSeparator1;
		private ToolStripMenuItem cmsAddBill;
		private ToolStripMenuItem cmsEditBill;
		private ToolStripSeparator toolStripSeparator2;
		private ToolStripMenuItem cmsSaveBill;
		private ToolStripMenuItem cmsAddProduct;
		private ToolStripSeparator toolStripSeparator4;
		private Button lblProduct;
		private Button lblMoney;
		private Button lblNumber;
		private Button lblUnit;
		private Label label4;
		private Label label22;
		private TextBox txtProductGuide;
		private ContextMenuStrip ctmBill;
		private ToolStripMenuItem ctmBillAdd;
		private ToolStripMenuItem ctmBillEdit;
		private ToolStripSeparator toolStripSeparator5;
		private ToolStripMenuItem ctmBillPrint;
		private ToolStripMenuItem ctmBillDel;
		private DataGridViewTextBoxColumn productName;
		private DataGridViewTextBoxColumn productUnit;
		private DataGridViewTextBoxColumn productNumber;
		private DataGridViewTextBoxColumn ProductID;
		private DataGridViewTextBoxColumn ProductGuide;
		private Label lblCountBill;
		private TextBox txtProductNumber1;
		private DataGridView dgvDisease;
		private TextBox txtID;
		private ToolStripMenuItem cmsDellBill;
		private TextBox txtNote;
		private Label label19;
		private DataGridViewTextBoxColumn D_Name;
		private DataGridViewTextBoxColumn ID;
		private DataGridViewTextBoxColumn billID;
		private DataGridViewTextBoxColumn DateCreate;
		private DataGridViewTextBoxColumn DeseaseID;
		private DataGridViewTextBoxColumn Note;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn11;
		private Func objFunc = new Func();
		public string userName = "";
		public string fullName = "";
		public string currDeseaseID = "0";
		public string currDeseaseName = "";
		public string currPid = "";
		public string strConnection = "";
		public string tmpUsage = "";
		public string doctorID = "";
		private customers objCus = new customers();
		private products objProduct = new products();
		private Doctor objDoctor = new Doctor();
		private DataTable objProductTable = new DataTable();
		private bool AllowSellSuppen = false;
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmTmpPrescription));
			DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle6 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle7 = new DataGridViewCellStyle();
			this.dgvBill = new DataGridView();
			this.ctmBill = new ContextMenuStrip(this.components);
			this.ctmBillAdd = new ToolStripMenuItem();
			this.ctmBillEdit = new ToolStripMenuItem();
			this.toolStripSeparator5 = new ToolStripSeparator();
			this.ctmBillPrint = new ToolStripMenuItem();
			this.ctmBillDel = new ToolStripMenuItem();
			this.btnClose = new Button();
			this.btnDel = new Button();
			this.btnSave = new Button();
			this.btnEdit = new Button();
			this.btnAdd = new Button();
			this.dgvProduct = new DataGridView();
			this.cmsBill = new ContextMenuStrip(this.components);
			this.cmsAddProduct = new ToolStripMenuItem();
			this.toolStripSeparator4 = new ToolStripSeparator();
			this.cmsDelProduct = new ToolStripMenuItem();
			this.toolStripSeparator1 = new ToolStripSeparator();
			this.cmsAddBill = new ToolStripMenuItem();
			this.cmsEditBill = new ToolStripMenuItem();
			this.toolStripSeparator2 = new ToolStripSeparator();
			this.cmsSaveBill = new ToolStripMenuItem();
			this.cmsDellBill = new ToolStripMenuItem();
			this.btnSelect = new Button();
			this.txtProductUnit = new TextBox();
			this.txtProductName = new TextBox();
			this.btnAddToBill = new Button();
			this.toolTip1 = new ToolTip(this.components);
			this.lblProduct = new Button();
			this.lblMoney = new Button();
			this.lblNumber = new Button();
			this.lblUnit = new Button();
			this.label4 = new Label();
			this.label22 = new Label();
			this.txtProductGuide = new TextBox();
			this.lblCountBill = new Label();
			this.txtProductNumber1 = new TextBox();
			this.dgvDisease = new DataGridView();
			this.txtID = new TextBox();
			this.txtNote = new TextBox();
			this.label19 = new Label();
			this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn4 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn5 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn6 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn7 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn8 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn9 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn10 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn11 = new DataGridViewTextBoxColumn();
			this.D_Name = new DataGridViewTextBoxColumn();
			this.ID = new DataGridViewTextBoxColumn();
			this.productName = new DataGridViewTextBoxColumn();
			this.productUnit = new DataGridViewTextBoxColumn();
			this.productNumber = new DataGridViewTextBoxColumn();
			this.ProductID = new DataGridViewTextBoxColumn();
			this.ProductGuide = new DataGridViewTextBoxColumn();
			this.billID = new DataGridViewTextBoxColumn();
			this.DateCreate = new DataGridViewTextBoxColumn();
			this.DeseaseID = new DataGridViewTextBoxColumn();
			this.Note = new DataGridViewTextBoxColumn();
			((ISupportInitialize)this.dgvBill).BeginInit();
			this.ctmBill.SuspendLayout();
			((ISupportInitialize)this.dgvProduct).BeginInit();
			this.cmsBill.SuspendLayout();
			((ISupportInitialize)this.dgvDisease).BeginInit();
			base.SuspendLayout();
			this.dgvBill.AllowUserToAddRows = false;
			this.dgvBill.AllowUserToDeleteRows = false;
			this.dgvBill.AllowUserToOrderColumns = true;
			this.dgvBill.AllowUserToResizeColumns = false;
			this.dgvBill.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvBill.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvBill.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.dgvBill.BackgroundColor = Color.White;
			this.dgvBill.BorderStyle = BorderStyle.Fixed3D;
			this.dgvBill.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvBill.Columns.AddRange(new DataGridViewColumn[]
			{
				this.billID,
				this.DateCreate,
				this.DeseaseID,
				this.Note
			});
			this.dgvBill.ContextMenuStrip = this.ctmBill;
			this.dgvBill.Cursor = Cursors.Hand;
			this.dgvBill.EnableHeadersVisualStyles = false;
			this.dgvBill.Location = new System.Drawing.Point(7, 306);
			this.dgvBill.MultiSelect = false;
			this.dgvBill.Name = "dgvBill";
			this.dgvBill.ReadOnly = true;
			this.dgvBill.RowHeadersVisible = false;
			this.dgvBill.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			this.dgvBill.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvBill.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvBill.Size = new Size(220, 230);
			this.dgvBill.TabIndex = 41;
			this.dgvBill.CellEnter += new DataGridViewCellEventHandler(this.dgvBill_CellEnter);
			this.ctmBill.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.ctmBill.Items.AddRange(new ToolStripItem[]
			{
				this.ctmBillAdd,
				this.ctmBillEdit,
				this.toolStripSeparator5,
				this.ctmBillPrint,
				this.ctmBillDel
			});
			this.ctmBill.Name = "ctmBill";
			this.ctmBill.Size = new Size(156, 98);
			this.ctmBillAdd.Name = "ctmBillAdd";
			this.ctmBillAdd.Size = new Size(155, 22);
			this.ctmBillAdd.Text = "Tạo đơn thuốc";
			this.ctmBillAdd.Click += new EventHandler(this.ctmBillAdd_Click);
			this.ctmBillEdit.Name = "ctmBillEdit";
			this.ctmBillEdit.Size = new Size(155, 22);
			this.ctmBillEdit.Text = "Sửa đơn thuốc";
			this.ctmBillEdit.Click += new EventHandler(this.ctmBillEdit_Click);
			this.toolStripSeparator5.Name = "toolStripSeparator5";
			this.toolStripSeparator5.Size = new Size(152, 6);
			this.ctmBillPrint.Name = "ctmBillPrint";
			this.ctmBillPrint.Size = new Size(155, 22);
			this.ctmBillPrint.Text = "In đơn thuốc";
			this.ctmBillDel.Name = "ctmBillDel";
			this.ctmBillDel.Size = new Size(155, 22);
			this.ctmBillDel.Text = "Xoá đơn thuốc";
			this.ctmBillDel.Click += new EventHandler(this.ctmBillDel_Click);
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.Cursor = Cursors.Hand;
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new System.Drawing.Point(853, 566);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(90, 30);
			this.btnClose.TabIndex = 25;
			this.btnClose.Text = "Thoát [ESC]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.btnDel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnDel.Cursor = Cursors.Hand;
			this.btnDel.Enabled = false;
			this.btnDel.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnDel.Location = new System.Drawing.Point(334, 566);
			this.btnDel.Name = "btnDel";
			this.btnDel.Size = new Size(102, 30);
			this.btnDel.TabIndex = 22;
			this.btnDel.Text = "Xoá đơn [ F8 ]";
			this.btnDel.UseVisualStyleBackColor = true;
			this.btnDel.Click += new EventHandler(this.btnDel_Click);
			this.btnDel.EnabledChanged += new EventHandler(this.btnDel_EnabledChanged);
			this.btnSave.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnSave.Cursor = Cursors.Hand;
			this.btnSave.Enabled = false;
			this.btnSave.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSave.Location = new System.Drawing.Point(228, 566);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new Size(106, 30);
			this.btnSave.TabIndex = 20;
			this.btnSave.Text = "Lưu đơn [ F6 ]";
			this.btnSave.UseVisualStyleBackColor = true;
			this.btnSave.Click += new EventHandler(this.btnSave_Click);
			this.btnSave.EnabledChanged += new EventHandler(this.btnSave_EnabledChanged);
			this.btnEdit.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnEdit.Cursor = Cursors.Hand;
			this.btnEdit.Enabled = false;
			this.btnEdit.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnEdit.Location = new System.Drawing.Point(108, 566);
			this.btnEdit.Name = "btnEdit";
			this.btnEdit.Size = new Size(120, 30);
			this.btnEdit.TabIndex = 24;
			this.btnEdit.Text = "Sửa đơn [ F5 ]";
			this.btnEdit.UseVisualStyleBackColor = true;
			this.btnEdit.Click += new EventHandler(this.btnEdit_Click);
			this.btnAdd.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnAdd.Cursor = Cursors.Hand;
			this.btnAdd.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnAdd.Location = new System.Drawing.Point(5, 566);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new Size(103, 30);
			this.btnAdd.TabIndex = 1;
			this.btnAdd.Text = "Thêm mới [ F4 ]";
			this.btnAdd.UseVisualStyleBackColor = true;
			this.btnAdd.Click += new EventHandler(this.btnAdd_Click);
			this.dgvProduct.AllowUserToAddRows = false;
			this.dgvProduct.AllowUserToDeleteRows = false;
			this.dgvProduct.AllowUserToOrderColumns = true;
			this.dgvProduct.AllowUserToResizeColumns = false;
			this.dgvProduct.AllowUserToResizeRows = false;
			dataGridViewCellStyle2.BackColor = Color.White;
			dataGridViewCellStyle2.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.dgvProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2;
			this.dgvProduct.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvProduct.BackgroundColor = Color.White;
			this.dgvProduct.BorderStyle = BorderStyle.Fixed3D;
			this.dgvProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
			this.dgvProduct.ColumnHeadersVisible = false;
			this.dgvProduct.Columns.AddRange(new DataGridViewColumn[]
			{
				this.productName,
				this.productUnit,
				this.productNumber,
				this.ProductID,
				this.ProductGuide
			});
			this.dgvProduct.ContextMenuStrip = this.cmsBill;
			this.dgvProduct.Cursor = Cursors.Hand;
			this.dgvProduct.EnableHeadersVisualStyles = false;
			this.dgvProduct.Location = new System.Drawing.Point(233, 61);
			this.dgvProduct.MultiSelect = false;
			this.dgvProduct.Name = "dgvProduct";
			this.dgvProduct.ReadOnly = true;
			this.dgvProduct.RowHeadersVisible = false;
			this.dgvProduct.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			this.dgvProduct.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.dgvProduct.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvProduct.Size = new Size(710, 475);
			this.dgvProduct.TabIndex = 16;
			this.toolTip1.SetToolTip(this.dgvProduct, "Bấm nút phải chuột để chọn\r\nmenu thao tác nhanh !");
			this.dgvProduct.KeyDown += new KeyEventHandler(this.dgvProduct_KeyDown);
			this.dgvProduct.CellEnter += new DataGridViewCellEventHandler(this.dgvProduct_CellEnter);
			this.cmsBill.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.cmsBill.Items.AddRange(new ToolStripItem[]
			{
				this.cmsAddProduct,
				this.toolStripSeparator4,
				this.cmsDelProduct,
				this.toolStripSeparator1,
				this.cmsAddBill,
				this.cmsEditBill,
				this.toolStripSeparator2,
				this.cmsSaveBill,
				this.cmsDellBill
			});
			this.cmsBill.Name = "cmsBill";
			this.cmsBill.Size = new Size(239, 154);
			this.cmsAddProduct.Name = "cmsAddProduct";
			this.cmsAddProduct.Size = new Size(238, 22);
			this.cmsAddProduct.Text = "Thêm thuốc vào đơn";
			this.cmsAddProduct.Click += new EventHandler(this.btnSelect_Click);
			this.toolStripSeparator4.Name = "toolStripSeparator4";
			this.toolStripSeparator4.Size = new Size(235, 6);
			this.cmsDelProduct.Name = "cmsDelProduct";
			this.cmsDelProduct.ShortcutKeys = Keys.Delete;
			this.cmsDelProduct.Size = new Size(238, 22);
			this.cmsDelProduct.Text = "Xoá thuốc khỏi đơn thuốc";
			this.cmsDelProduct.Click += new EventHandler(this.cmsDelProduct_Click);
			this.toolStripSeparator1.Name = "toolStripSeparator1";
			this.toolStripSeparator1.Size = new Size(235, 6);
			this.cmsAddBill.Name = "cmsAddBill";
			this.cmsAddBill.Size = new Size(238, 22);
			this.cmsAddBill.Text = "Tạo đơn thuốc";
			this.cmsAddBill.Click += new EventHandler(this.cmsAddBill_Click);
			this.cmsEditBill.Name = "cmsEditBill";
			this.cmsEditBill.Size = new Size(238, 22);
			this.cmsEditBill.Text = "Sửa đơn thuốc";
			this.cmsEditBill.Click += new EventHandler(this.cmsEditBill_Click);
			this.toolStripSeparator2.Name = "toolStripSeparator2";
			this.toolStripSeparator2.Size = new Size(235, 6);
			this.cmsSaveBill.Enabled = false;
			this.cmsSaveBill.Name = "cmsSaveBill";
			this.cmsSaveBill.Size = new Size(238, 22);
			this.cmsSaveBill.Text = "Lưu đơn thuốc";
			this.cmsSaveBill.Click += new EventHandler(this.cmsSaveBill_Click);
			this.cmsDellBill.Enabled = false;
			this.cmsDellBill.Name = "cmsDellBill";
			this.cmsDellBill.Size = new Size(238, 22);
			this.cmsDellBill.Text = "Xoá đơn thuốc";
			this.cmsDellBill.Click += new EventHandler(this.cmsDellBill_Click);
			this.btnSelect.BackColor = Color.White;
			this.btnSelect.Enabled = false;
			this.btnSelect.FlatAppearance.BorderColor = Color.Cyan;
			this.btnSelect.FlatStyle = FlatStyle.Flat;
//			this.btnSelect.Image = (Image)componentResourceManager.GetObject("btnSelect.Image");
			this.btnSelect.Location = new System.Drawing.Point(510, 35);
			this.btnSelect.Name = "btnSelect";
			this.btnSelect.Size = new Size(22, 16);
			this.btnSelect.TabIndex = 12;
			this.toolTip1.SetToolTip(this.btnSelect, "Chọn sản phẩm cần xuất");
			this.btnSelect.UseVisualStyleBackColor = false;
			this.btnSelect.Click += new EventHandler(this.btnSelect_Click);
			this.txtProductUnit.BackColor = Color.White;
			this.txtProductUnit.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtProductUnit.Location = new System.Drawing.Point(536, 32);
			this.txtProductUnit.Name = "txtProductUnit";
			this.txtProductUnit.ReadOnly = true;
			this.txtProductUnit.Size = new Size(108, 22);
			this.txtProductUnit.TabIndex = 13;
			this.txtProductUnit.TextChanged += new EventHandler(this.txtProductUnit_TextChanged);
			this.txtProductUnit.Leave += new EventHandler(this.txtProductUnit_Leave);
			this.txtProductUnit.KeyPress += new KeyPressEventHandler(this.txtProductUnit_KeyPress);
			this.txtProductUnit.Enter += new EventHandler(this.txtProductUnit_Enter);
			this.txtProductName.BackColor = Color.White;
			this.txtProductName.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtProductName.Location = new System.Drawing.Point(237, 32);
			this.txtProductName.Name = "txtProductName";
			this.txtProductName.Size = new Size(298, 22);
			this.txtProductName.TabIndex = 11;
			this.txtProductName.TextChanged += new EventHandler(this.txtProductName_TextChanged);
			this.txtProductName.KeyDown += new KeyEventHandler(this.txtProductName_KeyDown);
			this.txtProductName.Leave += new EventHandler(this.txtProductName_Leave);
			this.txtProductName.KeyPress += new KeyPressEventHandler(this.txtProductName_KeyPress);
			this.txtProductName.Enter += new EventHandler(this.txtProductName_Enter);
			this.btnAddToBill.BackColor = Color.White;
			this.btnAddToBill.Enabled = false;
			this.btnAddToBill.FlatAppearance.BorderColor = Color.FromArgb(192, 255, 255);
			this.btnAddToBill.FlatStyle = FlatStyle.Flat;
			this.btnAddToBill.Location = new System.Drawing.Point(12, 967);
			this.btnAddToBill.Name = "btnAddToBill";
			this.btnAddToBill.Size = new Size(140, 26);
			this.btnAddToBill.TabIndex = 200;
			this.btnAddToBill.Text = "Thêm sản phẩm  [ F3 ]";
			this.btnAddToBill.UseVisualStyleBackColor = false;
			this.btnAddToBill.Click += new EventHandler(this.btnAddToBill_Click);
			this.toolTip1.IsBalloon = true;
			this.lblProduct.Enabled = false;
			this.lblProduct.FlatAppearance.BorderSize = 0;
			this.lblProduct.FlatStyle = FlatStyle.Flat;
			this.lblProduct.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.lblProduct.Location = new System.Drawing.Point(237, 10);
			this.lblProduct.Name = "lblProduct";
			this.lblProduct.Size = new Size(298, 20);
			this.lblProduct.TabIndex = 178;
			this.lblProduct.Text = "TÊN THUỐC";
			this.lblProduct.UseVisualStyleBackColor = true;
			this.lblMoney.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.lblMoney.Enabled = false;
			this.lblMoney.FlatAppearance.BorderSize = 0;
			this.lblMoney.FlatStyle = FlatStyle.Flat;
			this.lblMoney.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.lblMoney.Location = new System.Drawing.Point(737, 10);
			this.lblMoney.Name = "lblMoney";
			this.lblMoney.Size = new Size(204, 20);
			this.lblMoney.TabIndex = 177;
			this.lblMoney.Text = "LIỀU DÙNG";
			this.lblMoney.UseVisualStyleBackColor = true;
			this.lblNumber.Enabled = false;
			this.lblNumber.FlatAppearance.BorderSize = 0;
			this.lblNumber.FlatStyle = FlatStyle.Flat;
			this.lblNumber.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.lblNumber.Location = new System.Drawing.Point(645, 10);
			this.lblNumber.Name = "lblNumber";
			this.lblNumber.Size = new Size(91, 20);
			this.lblNumber.TabIndex = 175;
			this.lblNumber.Text = "SỐ LƯỢNG";
			this.lblNumber.UseVisualStyleBackColor = true;
			this.lblUnit.Enabled = false;
			this.lblUnit.FlatAppearance.BorderSize = 0;
			this.lblUnit.FlatStyle = FlatStyle.Flat;
			this.lblUnit.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.lblUnit.Location = new System.Drawing.Point(536, 10);
			this.lblUnit.Name = "lblUnit";
			this.lblUnit.Size = new Size(108, 20);
			this.lblUnit.TabIndex = 174;
			this.lblUnit.Text = "ĐƠN VỊ TÍNH";
			this.lblUnit.UseVisualStyleBackColor = true;
			this.label4.BackColor = Color.FromArgb(255, 255, 192);
			this.label4.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.label4.Location = new System.Drawing.Point(7, 8);
			this.label4.Name = "label4";
			this.label4.Size = new Size(235, 23);
			this.label4.TabIndex = 172;
			this.label4.Text = "THÔNG TIN VỀ THUỐC :  ";
			this.label4.TextAlign = ContentAlignment.MiddleRight;
			this.label22.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.label22.BackColor = Color.FromArgb(255, 255, 192);
			this.label22.Location = new System.Drawing.Point(233, 8);
			this.label22.Name = "label22";
			this.label22.Size = new Size(710, 50);
			this.label22.TabIndex = 171;
			this.txtProductGuide.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.txtProductGuide.BackColor = Color.White;
			this.txtProductGuide.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtProductGuide.Location = new System.Drawing.Point(737, 32);
			this.txtProductGuide.Name = "txtProductGuide";
			this.txtProductGuide.Size = new Size(205, 22);
			this.txtProductGuide.TabIndex = 15;
			this.txtProductGuide.KeyDown += new KeyEventHandler(this.txtProductGuide_KeyDown);
			this.txtProductGuide.Leave += new EventHandler(this.txtProductGuide_Leave);
			this.txtProductGuide.Enter += new EventHandler(this.txtProductGuide_Enter);
			this.lblCountBill.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.lblCountBill.BackColor = Color.White;
			this.lblCountBill.BorderStyle = BorderStyle.Fixed3D;
			this.lblCountBill.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.lblCountBill.ForeColor = SystemColors.MenuText;
			this.lblCountBill.Location = new System.Drawing.Point(8, 539);
			this.lblCountBill.Name = "lblCountBill";
			this.lblCountBill.Size = new Size(220, 21);
			this.lblCountBill.TabIndex = 564;
			this.lblCountBill.TextAlign = ContentAlignment.MiddleCenter;
			this.txtProductNumber1.BackColor = Color.White;
			this.txtProductNumber1.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtProductNumber1.Location = new System.Drawing.Point(645, 32);
			this.txtProductNumber1.Name = "txtProductNumber1";
			this.txtProductNumber1.ReadOnly = true;
			this.txtProductNumber1.Size = new Size(91, 22);
			this.txtProductNumber1.TabIndex = 14;
			this.txtProductNumber1.TextAlign = HorizontalAlignment.Right;
			this.txtProductNumber1.KeyDown += new KeyEventHandler(this.txtProductNumber1_KeyDown);
			this.txtProductNumber1.Leave += new EventHandler(this.txtProductNumber1_Leave);
			this.txtProductNumber1.Enter += new EventHandler(this.txtProductNumber1_Enter);
			this.dgvDisease.AllowUserToAddRows = false;
			this.dgvDisease.AllowUserToDeleteRows = false;
			this.dgvDisease.AllowUserToOrderColumns = true;
			this.dgvDisease.AllowUserToResizeColumns = false;
			this.dgvDisease.AllowUserToResizeRows = false;
			dataGridViewCellStyle3.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle3.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.dgvDisease.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
			this.dgvDisease.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left);
			this.dgvDisease.BackgroundColor = Color.White;
			this.dgvDisease.BorderStyle = BorderStyle.Fixed3D;
			this.dgvDisease.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvDisease.Columns.AddRange(new DataGridViewColumn[]
			{
				this.D_Name,
				this.ID
			});
			this.dgvDisease.ContextMenuStrip = this.ctmBill;
			this.dgvDisease.Cursor = Cursors.Hand;
			this.dgvDisease.EnableHeadersVisualStyles = false;
			this.dgvDisease.Location = new System.Drawing.Point(8, 35);
			this.dgvDisease.MultiSelect = false;
			this.dgvDisease.Name = "dgvDisease";
			this.dgvDisease.ReadOnly = true;
			this.dgvDisease.RowHeadersVisible = false;
			this.dgvDisease.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			this.dgvDisease.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.dgvDisease.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvDisease.Size = new Size(220, 265);
			this.dgvDisease.TabIndex = 565;
			this.dgvDisease.CellEnter += new DataGridViewCellEventHandler(this.dgvDisease_CellEnter);
			this.txtID.BackColor = Color.White;
			this.txtID.CharacterCasing = CharacterCasing.Upper;
			this.txtID.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtID.Location = new System.Drawing.Point(237, 509);
			this.txtID.Name = "txtID";
			this.txtID.ReadOnly = true;
			this.txtID.Size = new Size(100, 22);
			this.txtID.TabIndex = 566;
			this.txtNote.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.txtNote.BackColor = Color.White;
			this.txtNote.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.txtNote.Location = new System.Drawing.Point(334, 539);
			this.txtNote.Name = "txtNote";
			this.txtNote.ReadOnly = true;
			this.txtNote.Size = new Size(609, 22);
			this.txtNote.TabIndex = 567;
			this.label19.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.label19.BackColor = Color.FromArgb(255, 255, 192);
			this.label19.BorderStyle = BorderStyle.Fixed3D;
			this.label19.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.label19.Location = new System.Drawing.Point(233, 539);
			this.label19.Name = "label19";
			this.label19.Size = new Size(101, 21);
			this.label19.TabIndex = 568;
			this.label19.Text = "Ghi chú :";
			this.label19.TextAlign = ContentAlignment.MiddleRight;
			this.dataGridViewTextBoxColumn1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dataGridViewTextBoxColumn1.DataPropertyName = "ID";
			this.dataGridViewTextBoxColumn1.HeaderText = "Đơn thuốc";
			this.dataGridViewTextBoxColumn1.MinimumWidth = 120;
			this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
			this.dataGridViewTextBoxColumn2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn2.DataPropertyName = "DateCreate";
			dataGridViewCellStyle4.Format = "D";
			dataGridViewCellStyle4.NullValue = null;
			this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle4;
			this.dataGridViewTextBoxColumn2.HeaderText = "Ngày lập";
			this.dataGridViewTextBoxColumn2.MinimumWidth = 88;
			this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
			this.dataGridViewTextBoxColumn2.Width = 88;
			this.dataGridViewTextBoxColumn3.DataPropertyName = "DeseaseID";
			this.dataGridViewTextBoxColumn3.HeaderText = "Loại bệnh";
			this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
			this.dataGridViewTextBoxColumn3.Visible = false;
			this.dataGridViewTextBoxColumn4.DataPropertyName = "Note";
			this.dataGridViewTextBoxColumn4.HeaderText = "Note";
			this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
			this.dataGridViewTextBoxColumn4.Visible = false;
			this.dataGridViewTextBoxColumn5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn5.DataPropertyName = "productName";
			this.dataGridViewTextBoxColumn5.HeaderText = "Sản phẩm";
			this.dataGridViewTextBoxColumn5.MinimumWidth = 300;
			this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
			this.dataGridViewTextBoxColumn5.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.dataGridViewTextBoxColumn5.Width = 300;
			this.dataGridViewTextBoxColumn6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn6.DataPropertyName = "productUnit";
			this.dataGridViewTextBoxColumn6.HeaderText = "Đơn vị tính";
			this.dataGridViewTextBoxColumn6.MinimumWidth = 110;
			this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
			this.dataGridViewTextBoxColumn6.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.dataGridViewTextBoxColumn6.Width = 110;
			this.dataGridViewTextBoxColumn7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn7.DataPropertyName = "productNumber";
			dataGridViewCellStyle5.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle5.Format = "N0";
			dataGridViewCellStyle5.NullValue = null;
			this.dataGridViewTextBoxColumn7.DefaultCellStyle = dataGridViewCellStyle5;
			this.dataGridViewTextBoxColumn7.HeaderText = "Số lượng";
			this.dataGridViewTextBoxColumn7.MinimumWidth = 92;
			this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
			this.dataGridViewTextBoxColumn7.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.dataGridViewTextBoxColumn7.Width = 92;
			this.dataGridViewTextBoxColumn8.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn8.DataPropertyName = "ProductID";
			this.dataGridViewTextBoxColumn8.HeaderText = "Mã sản phẩm";
			this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
			this.dataGridViewTextBoxColumn8.Visible = false;
			this.dataGridViewTextBoxColumn9.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dataGridViewTextBoxColumn9.DataPropertyName = "ProductGuide";
			this.dataGridViewTextBoxColumn9.HeaderText = "Liều dùng";
			this.dataGridViewTextBoxColumn9.MinimumWidth = 100;
			this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
			this.dataGridViewTextBoxColumn10.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dataGridViewTextBoxColumn10.DataPropertyName = "Name";
			this.dataGridViewTextBoxColumn10.HeaderText = "Loại bệnh";
			this.dataGridViewTextBoxColumn10.MinimumWidth = 120;
			this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
			this.dataGridViewTextBoxColumn11.DataPropertyName = "ID";
			this.dataGridViewTextBoxColumn11.HeaderText = "DID";
			this.dataGridViewTextBoxColumn11.Name = "dataGridViewTextBoxColumn11";
			this.dataGridViewTextBoxColumn11.Visible = false;
			this.D_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.D_Name.DataPropertyName = "Name";
			this.D_Name.HeaderText = "Loại bệnh";
			this.D_Name.MinimumWidth = 120;
			this.D_Name.Name = "D_Name";
			this.D_Name.ReadOnly = true;
			this.ID.DataPropertyName = "ID";
			this.ID.HeaderText = "DID";
			this.ID.Name = "ID";
			this.ID.ReadOnly = true;
			this.ID.Visible = false;
			this.productName.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.productName.DataPropertyName = "productName";
			this.productName.HeaderText = "Sản phẩm";
			this.productName.MinimumWidth = 300;
			this.productName.Name = "productName";
			this.productName.ReadOnly = true;
			this.productName.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.productName.Width = 300;
			this.productUnit.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.productUnit.DataPropertyName = "productUnit";
			this.productUnit.HeaderText = "Đơn vị tính";
			this.productUnit.MinimumWidth = 110;
			this.productUnit.Name = "productUnit";
			this.productUnit.ReadOnly = true;
			this.productUnit.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.productUnit.Width = 110;
			this.productNumber.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.productNumber.DataPropertyName = "productNumber";
			dataGridViewCellStyle6.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle6.Format = "N0";
			dataGridViewCellStyle6.NullValue = null;
			this.productNumber.DefaultCellStyle = dataGridViewCellStyle6;
			this.productNumber.HeaderText = "Số lượng";
			this.productNumber.MinimumWidth = 92;
			this.productNumber.Name = "productNumber";
			this.productNumber.ReadOnly = true;
			this.productNumber.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.productNumber.Width = 92;
			this.ProductID.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.ProductID.DataPropertyName = "ProductID";
			this.ProductID.HeaderText = "Mã sản phẩm";
			this.ProductID.Name = "ProductID";
			this.ProductID.ReadOnly = true;
			this.ProductID.Visible = false;
			this.ProductGuide.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.ProductGuide.DataPropertyName = "ProductGuide";
			this.ProductGuide.HeaderText = "Liều dùng";
			this.ProductGuide.MinimumWidth = 100;
			this.ProductGuide.Name = "ProductGuide";
			this.ProductGuide.ReadOnly = true;
			this.billID.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.billID.DataPropertyName = "ID";
			this.billID.HeaderText = "Đơn thuốc";
			this.billID.MinimumWidth = 120;
			this.billID.Name = "billID";
			this.billID.ReadOnly = true;
			this.DateCreate.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.DateCreate.DataPropertyName = "DateCreate";
			dataGridViewCellStyle7.Format = "D";
			dataGridViewCellStyle7.NullValue = null;
			this.DateCreate.DefaultCellStyle = dataGridViewCellStyle7;
			this.DateCreate.HeaderText = "Ngày lập";
			this.DateCreate.MinimumWidth = 88;
			this.DateCreate.Name = "DateCreate";
			this.DateCreate.ReadOnly = true;
			this.DateCreate.Width = 88;
			this.DeseaseID.DataPropertyName = "DeseaseID";
			this.DeseaseID.HeaderText = "Loại bệnh";
			this.DeseaseID.Name = "DeseaseID";
			this.DeseaseID.ReadOnly = true;
			this.DeseaseID.Visible = false;
			this.Note.DataPropertyName = "Note";
			this.Note.HeaderText = "Note";
			this.Note.Name = "Note";
			this.Note.ReadOnly = true;
			this.Note.Visible = false;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(950, 600);
			base.Controls.Add(this.txtNote);
			base.Controls.Add(this.label19);
			base.Controls.Add(this.dgvDisease);
			base.Controls.Add(this.txtProductNumber1);
			base.Controls.Add(this.txtProductGuide);
			base.Controls.Add(this.lblProduct);
			base.Controls.Add(this.lblMoney);
			base.Controls.Add(this.btnSelect);
			base.Controls.Add(this.lblUnit);
			base.Controls.Add(this.lblNumber);
			base.Controls.Add(this.txtProductUnit);
			base.Controls.Add(this.label4);
			base.Controls.Add(this.txtProductName);
			base.Controls.Add(this.btnDel);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.btnSave);
			base.Controls.Add(this.btnEdit);
			base.Controls.Add(this.btnAdd);
			base.Controls.Add(this.label22);
			base.Controls.Add(this.dgvProduct);
			base.Controls.Add(this.dgvBill);
			base.Controls.Add(this.btnAddToBill);
			base.Controls.Add(this.lblCountBill);
			base.Controls.Add(this.txtID);
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.Name = "frmTmpPrescription";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "TẠO MẪU ĐƠN THUỐC";
			base.Load += new EventHandler(this.frmOutputRetail_Load);
			base.Shown += new EventHandler(this.frmOutputRetailWithDoctor_Shown);
			base.FormClosing += new FormClosingEventHandler(this.frmOutputRetailWithDoctor_FormClosing);
			base.KeyDown += new KeyEventHandler(this.frmOutputRetail_KeyDown);
			((ISupportInitialize)this.dgvBill).EndInit();
			this.ctmBill.ResumeLayout(false);
			((ISupportInitialize)this.dgvProduct).EndInit();
			this.cmsBill.ResumeLayout(false);
			((ISupportInitialize)this.dgvDisease).EndInit();
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmTmpPrescription()
		{
			this.InitializeComponent();
		}
		private void frmOutputRetail_Load(object sender, EventArgs e)
		{
			this.getDesease(this.dgvDisease);
			this.getBill();
			this.btnAdd.PerformClick();
		}
		public void getDesease(DataGridView dgv)
		{
			dgv.AutoGenerateColumns = false;
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			string selectCommandText = "SELECT ID, Name FROM [TabDesease] ORDER BY [Name]";
			SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommandText, sqlConnection);
			DataSet dataSet = new DataSet();
			sqlDataAdapter.Fill(dataSet);
			dgv.DataSource = dataSet.Tables[0];
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void frmOutputRetail_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
			else
			{
				if (e.KeyCode == Keys.F2)
				{
					this.btnSelect.PerformClick();
				}
				else
				{
					if (e.KeyCode == Keys.F3)
					{
						this.btnAddToBill.PerformClick();
					}
					else
					{
						if (e.KeyCode == Keys.F4)
						{
							this.btnAdd.PerformClick();
						}
						else
						{
							if (e.KeyCode == Keys.F5)
							{
								this.btnEdit.PerformClick();
							}
							else
							{
								if (e.KeyCode == Keys.F6)
								{
									this.btnSave.PerformClick();
								}
								else
								{
									if (e.KeyCode == Keys.F8)
									{
										this.btnDel.PerformClick();
									}
								}
							}
						}
					}
				}
			}
		}
		private void btnSave_Click(object sender, EventArgs e)
		{
			if (this.dgvProduct.Rows.Count == 0)
			{
				MessageBox.Show("Bạn chưa chọn loại thuốc cần kê đơn !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
			else
			{
				if (this.txtID.Text.Trim() != "-:-")
				{
					this.objDoctor.saveTmpPrescription(this.txtID.Text, DateTime.Now, this.currDeseaseID, this.txtNote.Text, this.doctorID);
				}
				else
				{
					this.txtID.Text = this.objDoctor.saveTmpPrescription(this.txtID.Text, DateTime.Now, this.currDeseaseID, this.txtNote.Text, this.doctorID);
				}
				this.objDoctor.saveTmpPrescriptionDetail(this.txtID.Text, this.objProductTable);
				this.getBill();
				this.EnableControl(false);
			}
		}
		private void btnEdit_Click(object sender, EventArgs e)
		{
			this.EnableControl(true);
		}
		private void btnAdd_Click(object sender, EventArgs e)
		{
			this.objProductTable = new DataTable();
			DataColumn column = new DataColumn("ProductID", typeof(string));
			DataColumn column2 = new DataColumn("ProductName", typeof(string));
			DataColumn column3 = new DataColumn("ProductUnit", typeof(string));
			DataColumn column4 = new DataColumn("ProductNumber", typeof(string));
			DataColumn column5 = new DataColumn("ProductGuide", typeof(string));
			this.objProductTable.Columns.Add(column);
			this.objProductTable.Columns.Add(column2);
			this.objProductTable.Columns.Add(column3);
			this.objProductTable.Columns.Add(column4);
			this.objProductTable.Columns.Add(column5);
			this.dgvProduct.DataSource = this.objProductTable;
			this.txtProductName.Text = "";
			this.txtProductUnit.Text = "";
			this.txtProductGuide.Text = "";
			this.txtNote.Text = this.currDeseaseName;
			this.currPid = "0";
			this.txtProductNumber1.Text = "";
			this.EnableControl(true);
			this.txtID.Text = "-:-";
			this.txtProductName.Focus();
		}
		private void EnableControl(bool Act)
		{
			this.txtNote.ReadOnly = !Act;
			this.btnAddToBill.Enabled = Act;
			this.btnSelect.Enabled = Act;
			this.btnSave.Enabled = Act;
		}
		private void btnDel_Click(object sender, EventArgs e)
		{
			if (this.txtID.Text.Trim() != "-:-")
			{
				if (MessageBox.Show("Bạn có chắc chắn muốn xoá đơn thuốc [ " + this.txtID.Text.ToUpper() + " ] không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
				{
					this.objDoctor.delTmpPrescription(this.txtID.Text);
					this.EnableControl(true);
					this.txtID.Text = "-:-";
					this.getBill();
				}
			}
		}
		private void btnSelect_Click(object sender, EventArgs e)
		{
			if (this.btnSave.Enabled)
			{
				this.tmpUsage = "";
				this.txtProductNumber1.Text = "1";
				this.txtProductName.Text = "";
				this.txtProductUnit.Text = "";
				this.txtProductGuide.Text = "";
				frmSelectProduct frmSelectProduct = new frmSelectProduct();
				frmSelectProduct.txtSearch.Text = this.txtProductName.Text;
				frmSelectProduct.isInput = true;
				frmSelectProduct.Location = new System.Drawing.Point(this.txtProductName.Location.X + 90, this.btnSelect.Location.Y + 80);
				frmSelectProduct.ShowDialog();
				if (frmSelectProduct.productID != "")
				{
					if (!this.AllowSellSuppen)
					{
						if (this.objProduct.checkForSuppend(frmSelectProduct.productID, "0"))
						{
							MessageBox.Show("Bạn đang chọn mặt thuốc\r\n\r\n" + frmSelectProduct.productName + "\r\n\r\nThuộc danh mục thuốc cấm lưu hành nên không thể nhập kho", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
							return;
						}
					}
					this.currPid = frmSelectProduct.productID;
					this.txtProductName.Text = frmSelectProduct.productName;
					this.txtProductUnit.Text = frmSelectProduct.unitName;
					this.tmpUsage = this.getUsageProduct(this.currPid);
					this.txtProductGuide.Text = this.tmpUsage;
					this.txtProductNumber1.Focus();
				}
			}
		}
		private void btnAddToBill_Click(object sender, EventArgs e)
		{
			try
			{
				if (this.txtProductName.Text.Trim() == "")
				{
					MessageBox.Show("Bạn chưa chọn loại thuốc cần kê đơn !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					this.txtProductName.Focus();
				}
				else
				{
					if (this.txtProductUnit.Text.Trim() == "")
					{
						MessageBox.Show("Bạn chưa chọn đơn vị tính của loại thuốc cần kê đơn !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
						this.txtProductUnit.Focus();
					}
					else
					{
						if (this.txtProductNumber1.Text.Trim() == "0" || this.txtProductNumber1.Text.Trim() == "")
						{
							MessageBox.Show("Bạn chưa chọn số lượng thuốc cần kê đơn !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
							this.txtProductNumber1.Focus();
						}
						else
						{
							try
							{
								double num = double.Parse(this.txtProductNumber1.Text);
							}
							catch
							{
								MessageBox.Show("Bạn chưa chọn số lượng thuốc cần kê đơn !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
								this.txtProductNumber1.Focus();
								return;
							}
							int num2 = this.checkInObjTable(this.currPid);
							if (num2 == -1)
							{
								this.objProductTable.Rows.Add(new object[]
								{
									this.currPid,
									this.txtProductName.Text,
									this.txtProductUnit.Text,
									this.txtProductNumber1.Text,
									this.txtProductGuide.Text
								});
							}
							else
							{
								this.updateObjTable(num2);
							}
							if (this.tmpUsage != "" && this.txtProductGuide.Text.Trim() != this.tmpUsage.Trim())
							{
								this.UpdateUsageProduct(this.currPid, this.txtProductGuide.Text);
							}
							this.dgvProduct.DataSource = this.objProductTable;
							this.txtProductName.Text = "";
							this.txtProductUnit.Text = "";
							this.txtProductNumber1.Text = "1";
							this.txtProductGuide.Text = "";
							this.txtProductName.Focus();
						}
					}
				}
			}
			catch
			{
			}
		}
		private void updateObjTable(int index)
		{
			this.objProductTable.Rows[index]["ProductID"] = this.currPid;
			this.objProductTable.Rows[index]["ProductName"] = this.txtProductName.Text;
			this.objProductTable.Rows[index]["ProductUnit"] = this.txtProductUnit.Text;
			this.objProductTable.Rows[index]["ProductNumber"] = this.txtProductNumber1.Text;
			this.objProductTable.Rows[index]["ProductGuide"] = this.txtProductGuide.Text;
		}
		private void txtProductName_TextChanged(object sender, EventArgs e)
		{
		}
		private void getBill()
		{
			try
			{
				this.txtNote.Text = "";
				this.txtProductName.Text = "";
				this.txtProductUnit.Text = "";
				this.txtProductGuide.Text = "";
				this.dgvBill.AutoGenerateColumns = false;
				this.dgvProduct.DataSource = null;
				this.dgvProduct.AutoGenerateColumns = false;
				SqlConnection sqlConnection = new SqlConnection(this.objFunc.strConnectionString);
				string cmdText = string.Concat(new string[]
				{
					"SELECT * FROM [TabTmpPrescription] WHERE [DeseaseID] = ",
					this.currDeseaseID,
					" AND [DoctorID] = '",
					this.doctorID,
					"' ORDER BY [DateCreate], [ID] DESC"
				});
				SqlCommand selectCommand = new SqlCommand(cmdText, sqlConnection);
				SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommand);
				DataSet dataSet = new DataSet();
				sqlConnection.Open();
				sqlDataAdapter.Fill(dataSet);
				this.dgvBill.DataSource = dataSet.Tables[0];
				this.lblCountBill.Text = "Hiện có : " + dataSet.Tables[0].Rows.Count.ToString() + " đơn thuốc";
				sqlConnection.Close();
				sqlConnection.Dispose();
				sqlDataAdapter.Dispose();
				dataSet.Dispose();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		private void txtProductUnit_TextChanged(object sender, EventArgs e)
		{
		}
		private void txtProductNumber_TextChanged(object sender, EventArgs e)
		{
		}
		private void dgvBill_CellEnter(object sender, DataGridViewCellEventArgs e)
		{
			try
			{
				this.objProductTable = new DataTable();
				this.txtID.Text = this.dgvBill.Rows[e.RowIndex].Cells["billID"].Value.ToString();
				this.currDeseaseID = this.dgvBill.Rows[e.RowIndex].Cells["DeseaseID"].Value.ToString();
				this.txtNote.Text = this.dgvBill.Rows[e.RowIndex].Cells["Note"].Value.ToString();
				this.objProductTable = this.objDoctor.getTmpPrescriptionDetail(this.txtID.Text);
				this.dgvProduct.DataSource = this.objProductTable;
				this.btnSave.Enabled = false;
				this.btnEdit.Enabled = true;
				this.btnDel.Enabled = true;
				this.txtNote.ReadOnly = true;
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		private void dgvProduct_CellEnter(object sender, DataGridViewCellEventArgs e)
		{
			this.currPid = this.dgvProduct.Rows[e.RowIndex].Cells["ProductID"].Value.ToString();
			this.txtProductName.Text = this.dgvProduct.Rows[e.RowIndex].Cells["ProductName"].Value.ToString();
			this.txtProductUnit.Text = this.dgvProduct.Rows[e.RowIndex].Cells["ProductUnit"].Value.ToString();
			this.txtProductNumber1.Text = this.dgvProduct.Rows[e.RowIndex].Cells["ProductNumber"].Value.ToString();
			this.txtProductGuide.Text = this.dgvProduct.Rows[e.RowIndex].Cells["ProductGuide"].Value.ToString();
		}
		private void dgvProduct_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Delete && this.btnSave.Enabled)
			{
				for (int i = 0; i < this.objProductTable.Rows.Count; i++)
				{
					if (this.objProductTable.Rows[i]["ProductID"].ToString() == this.currPid)
					{
						this.objProductTable.Rows[i].Delete();
						break;
					}
				}
				this.dgvProduct.DataSource = this.objProductTable;
				this.dgvProduct.Refresh();
			}
		}
		private void cbbPacket_SelectedIndexChanged(object sender, EventArgs e)
		{
		}
		private void dtpSelectMonth_ValueChanged(object sender, EventArgs e)
		{
		}
		private void txtBarcode_TextChanged(object sender, EventArgs e)
		{
		}
		private void btnSearch_Click(object sender, EventArgs e)
		{
		}
		private void btnViewAll_Click(object sender, EventArgs e)
		{
		}
		private void txtProductNumber_Leave(object sender, EventArgs e)
		{
			this.txtProductNumber1.BackColor = Color.White;
		}
		private void txtProductMoney_Leave(object sender, EventArgs e)
		{
			this.objFunc.txtObject_Leave(sender);
		}
		private void txtBalancer_Leave(object sender, EventArgs e)
		{
			this.objFunc.txtObject_Leave(sender);
		}
		private void txtTotalMoney_Leave(object sender, EventArgs e)
		{
			this.objFunc.txtObject_Leave(sender);
		}
		private void txtTotalMoney_TextChanged(object sender, EventArgs e)
		{
			this.objFunc.txtObject_Leave(sender);
		}
		private void btnListUnit_Click(object sender, EventArgs e)
		{
		}
		private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
		{
		}
		private void cmsAddBill_Click(object sender, EventArgs e)
		{
			this.btnAdd.PerformClick();
		}
		private void cmsEditBill_Click(object sender, EventArgs e)
		{
			this.btnEdit.PerformClick();
		}
		private void cmsSaveBill_Click(object sender, EventArgs e)
		{
			this.btnSave.PerformClick();
		}
		private void cmsDellBill_Click(object sender, EventArgs e)
		{
			this.btnDel.PerformClick();
		}
		private void btnSave_EnabledChanged(object sender, EventArgs e)
		{
			this.cmsAddProduct.Enabled = this.btnSave.Enabled;
			this.cmsSaveBill.Enabled = this.btnSave.Enabled;
			this.cmsDelProduct.Enabled = this.btnSave.Enabled;
			this.txtProductName.ReadOnly = !this.btnSave.Enabled;
			this.txtProductNumber1.ReadOnly = !this.btnSave.Enabled;
			this.txtProductUnit.ReadOnly = !this.btnSave.Enabled;
			this.txtProductGuide.ReadOnly = !this.btnSave.Enabled;
		}
		private void btnDel_EnabledChanged(object sender, EventArgs e)
		{
			this.cmsDellBill.Enabled = this.btnDel.Enabled;
		}
		private void txtProductNumber_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Return)
			{
				this.txtProductGuide.Focus();
			}
		}
		private void txtProductName_KeyPress(object sender, KeyPressEventArgs e)
		{
		}
		private void txtProductUnit_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtProductNumber1.Focus();
			}
		}
		private void cbbPacket_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtProductUnit.Focus();
			}
		}
		private void txtProductPrice_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtProductNumber1.Focus();
			}
		}
		private void txtProductNumber_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.btnAddToBill.PerformClick();
			}
		}
		private void txtNote_KeyPress(object sender, KeyPressEventArgs e)
		{
		}
		private void txtDoctor_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtProductName.Focus();
			}
		}
		private void txtProductName_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyData == Keys.Down)
			{
				if (this.txtProductName.Text.Trim() != "")
				{
					this.btnSelect.PerformClick();
				}
			}
			else
			{
				if (e.KeyData == Keys.Return)
				{
					this.txtProductUnit.Focus();
				}
			}
		}
		private void txtID_Enter(object sender, EventArgs e)
		{
			this.txtID.BackColor = Color.Aqua;
		}
		private void txtID_Leave(object sender, EventArgs e)
		{
			this.txtID.BackColor = Color.White;
		}
		private void txtProductName_Enter(object sender, EventArgs e)
		{
			this.txtProductName.BackColor = Color.Aqua;
		}
		private void txtProductName_Leave(object sender, EventArgs e)
		{
			this.txtProductName.BackColor = Color.White;
		}
		private void txtProductUnit_Enter(object sender, EventArgs e)
		{
			this.txtProductUnit.BackColor = Color.Aqua;
		}
		private void txtProductUnit_Leave(object sender, EventArgs e)
		{
			this.txtProductUnit.BackColor = Color.White;
		}
		private void txtProductPrice_Enter(object sender, EventArgs e)
		{
		}
		private void txtProductPrice_Leave(object sender, EventArgs e)
		{
		}
		private void txtProductNumber_Enter(object sender, EventArgs e)
		{
			this.txtProductNumber1.BackColor = Color.Aqua;
		}
		private void frmOutputRetailWithDoctor_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (this.btnSave.Enabled)
			{
				if (MessageBox.Show("Bạn có muốn ghi lại thông tin về hoá đơn hiện tại không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
				{
					e.Cancel = true;
					this.btnSave.PerformClick();
				}
			}
		}
		private void frmOutputRetailWithDoctor_Shown(object sender, EventArgs e)
		{
			this.btnAdd.PerformClick();
		}
		private void btnSearchTime_Click(object sender, EventArgs e)
		{
			this.getBill();
		}
		private void txtMoney_TextChanged(object sender, EventArgs e)
		{
		}
		private void txtDiscountOut_TextChanged(object sender, EventArgs e)
		{
		}
		private void txtDiscountOut_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.btnSave.PerformClick();
			}
		}
		private void txtMoneyAfterDiscount_Leave(object sender, EventArgs e)
		{
		}
		private void ctmBillAdd_Click(object sender, EventArgs e)
		{
			this.btnAdd.PerformClick();
		}
		private void ctmBillEdit_Click(object sender, EventArgs e)
		{
			this.btnEdit.PerformClick();
		}
		private void ctmBillDel_Click(object sender, EventArgs e)
		{
			this.btnDel.PerformClick();
		}
		private void txtProductGuide_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Return)
			{
				this.btnAddToBill.PerformClick();
			}
		}
		private void txtProductGuide_Enter(object sender, EventArgs e)
		{
			this.txtProductGuide.BackColor = Color.Aqua;
		}
		private void txtProductGuide_Leave(object sender, EventArgs e)
		{
			this.txtProductGuide.BackColor = Color.White;
		}
		private int checkInObjTable(string Pid)
		{
			int num = -1;
			int result;
			for (int i = 0; i < this.objProductTable.Rows.Count; i++)
			{
				if (this.objProductTable.Rows[i]["ProductID"].ToString() == Pid)
				{
					result = i;
					return result;
				}
			}
			result = num;
			return result;
		}
		private void cmsDelProduct_Click(object sender, EventArgs e)
		{
			if (this.btnSave.Enabled)
			{
				try
				{
					for (int i = 0; i < this.objProductTable.Rows.Count; i++)
					{
						if (this.objProductTable.Rows[i]["ProductID"].ToString() == this.currPid)
						{
							this.objProductTable.Rows[i].Delete();
							break;
						}
					}
					this.dgvProduct.DataSource = this.objProductTable;
					this.dgvProduct.Refresh();
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
		}
		private void txtProductNumber1_Enter(object sender, EventArgs e)
		{
			this.txtProductNumber1.BackColor = Color.Aqua;
		}
		private void txtProductNumber1_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Return)
			{
				this.txtProductGuide.Focus();
			}
		}
		private void txtProductNumber1_Leave(object sender, EventArgs e)
		{
			this.txtProductNumber1.BackColor = Color.White;
		}
		public string getUsageProduct(string Pid)
		{
			string result = "";
			try
			{
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				sqlConnection.Open();
				SqlCommand sqlCommand = new SqlCommand("SELECT [Usage] FROM [TabProducts] WHERE [Pid] = " + Pid, sqlConnection);
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				while (sqlDataReader.Read())
				{
					result = sqlDataReader["Usage"].ToString();
				}
				sqlDataReader.Close();
				sqlConnection.Close();
				sqlConnection.Dispose();
			}
			catch
			{
			}
			return result;
		}
		private void UpdateUsageProduct(string tmpID, string Usage)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = new SqlCommand("UpdateUsageOfProduct", sqlConnection);
			sqlCommand.CommandType = CommandType.StoredProcedure;
			sqlCommand.Parameters.Add("PID", SqlDbType.Int);
			sqlCommand.Parameters.Add("Usage", SqlDbType.NVarChar, 2000);
			sqlCommand.Parameters["PID"].Value = tmpID;
			sqlCommand.Parameters["Usage"].Value = Usage;
			sqlCommand.ExecuteNonQuery();
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private void dgvDisease_CellEnter(object sender, DataGridViewCellEventArgs e)
		{
			try
			{
				this.currDeseaseID = this.dgvDisease.Rows[e.RowIndex].Cells["ID"].Value.ToString();
				this.currDeseaseName = this.dgvDisease.Rows[e.RowIndex].Cells["D_Name"].Value.ToString();
				this.getBill();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
	}
}
